#include "wifi_connect.h"

WiFi_Connect::WiFi_Connect(QWidget *parent) : QWidget(parent)
{
    wifi_process = new QProcess(this);

    connect(wifi_process, SIGNAL(readyReadStandardOutput()),this, SLOT(process_result()));
    connect(wifi_process, SIGNAL(readyReadStandardError()),this, SLOT(process_result()));

    wifi_connect();
}

WiFi_Connect::~WiFi_Connect()
{

}

void WiFi_Connect::wifi_connect(void)
{
    wifi_process->start(tr("/usr/bin/elf1_cmd_wifi.sh -i %1 -s %2 -p %3")
                    .arg("8723")
                    .arg(DEFAULT_SSID)
                    .arg(DEFAULT_PWD));
}

void WiFi_Connect::process_result(void)
{
    QString output = wifi_process->readAllStandardOutput();

    QString error = wifi_process->readAllStandardError();

}

void WiFi_Connect::closeEvent(QCloseEvent *)
{
    wifi_process->kill();
    destroy();
    exit(0);
}
